home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.Toolkit;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.net.URL;
-
- public class JglFrame extends Applet implements Runnable {
- public static final String VERSION = "VIPER STG for JAVA";
- private Thread tMain;
- private GameFrame gameframe;
- protected int Width = 320;
- protected int Height = 240;
- protected boolean fApplication = false;
- protected int RefreshRate = 16;
- private long StartFrame;
- private long EndFrame;
- private long WaitFrame;
- protected Image iOffscreen;
- protected Graphics gOffscreen;
- protected Bg bg1;
- protected Sprite sprite;
- protected SpriteAnime spriteanime;
- protected JglPad jglpad;
- private short KeyNomal;
- // $FF: renamed from: SE Sound
- protected Sound field_0;
- protected Sound BGM;
- protected int CurtainHeight;
- protected int MovieHeight;
- protected boolean fFlush;
- protected boolean fFocus;
-
- public void setSizeWidth(int var1) {
- this.Width = var1;
- }
-
- public void setSizeHeight(int var1) {
- this.Height = var1;
- }
-
- public void setFlagApplication(boolean var1) {
- this.fApplication = var1;
- }
-
- public void setRefreshRate(int var1) {
- this.RefreshRate = var1;
- }
-
- public void setBg1(Bg var1) {
- this.bg1 = var1;
- }
-
- public void setSprite(Sprite var1) {
- this.sprite = var1;
- }
-
- public void setSpriteAnime(SpriteAnime var1) {
- this.spriteanime = var1;
- }
-
- public void setJglPad(JglPad var1) {
- this.jglpad = var1;
- }
-
- public void setSE(Sound var1) {
- this.field_0 = var1;
- }
-
- public void setBGM(Sound var1) {
- this.BGM = var1;
- }
-
- public void setCurtainHeight(int var1) {
- this.CurtainHeight = var1;
- }
-
- public void setMovieHeight(int var1) {
- this.MovieHeight = var1;
- }
-
- public void setFlush(boolean var1) {
- this.fFlush = var1;
- }
-
- public int getSizeWidth() {
- return this.Width;
- }
-
- public int getSizeHeight() {
- return this.Height;
- }
-
- public boolean getFlagApplication() {
- return this.fApplication;
- }
-
- public int getRefreshRate() {
- return this.RefreshRate;
- }
-
- public Bg getBg1() {
- return this.bg1;
- }
-
- public Sprite getSprite() {
- return this.sprite;
- }
-
- public SpriteAnime getSpriteAnime() {
- return this.spriteanime;
- }
-
- public JglPad getJglPad() {
- return this.jglpad;
- }
-
- public Sound getSE() {
- return this.field_0;
- }
-
- public Sound getBGM() {
- return this.BGM;
- }
-
- protected int getCurtainHeight() {
- return this.CurtainHeight;
- }
-
- protected int getMovieHeight() {
- return this.MovieHeight;
- }
-
- public boolean getFlush() {
- return this.fFlush;
- }
-
- public boolean getFocus() {
- return this.fFocus;
- }
-
- public InputStream openStream(String var1) {
- Object var2 = null;
-
- try {
- if (this.getFlagApplication()) {
- var2 = new FileInputStream(var1);
- } else {
- var2 = (new URL(((Applet)this).getDocumentBase(), var1)).openStream();
- }
- } catch (Exception var3) {
- }
-
- return (InputStream)var2;
- }
-
- public Image getImage(String var1) {
- MediaTracker var2 = new MediaTracker(this);
- Image var3;
- if (this.getFlagApplication()) {
- var3 = Toolkit.getDefaultToolkit().getImage(var1);
- } else {
- var3 = super.getImage(((Applet)this).getCodeBase(), var1);
- }
-
- var2.addImage(var3, 0);
-
- try {
- var2.waitForAll();
- } catch (InterruptedException var4) {
- }
-
- return var3;
- }
-
- public Image getImage(String var1, boolean var2) {
- MediaTracker var3 = new MediaTracker(this);
- Image var4;
- if (this.getFlagApplication()) {
- var4 = Toolkit.getDefaultToolkit().getImage(var1);
- } else {
- var4 = super.getImage(((Applet)this).getCodeBase(), var1);
- }
-
- if (var2) {
- var3.addImage(var4, 0);
-
- try {
- var3.waitForAll();
- } catch (InterruptedException var5) {
- }
- }
-
- return var4;
- }
-
- public AudioClip getAudioClip(String var1) {
- Object var2 = null;
- AudioClip var3;
- if (this.getFlagApplication()) {
- var3 = null;
- } else {
- var3 = super.getAudioClip(((Applet)this).getCodeBase(), var1);
- }
-
- return var3;
- }
-
- public void init() {
- this.fFocus = true;
- ((Applet)this).resize(this.Width, this.Height);
- ((Component)this).setBackground(Color.black);
- this.iOffscreen = ((Component)this).createImage(this.Width, this.Height);
- this.gOffscreen = this.iOffscreen.getGraphics();
- this.sprite = new Sprite(this, 0);
- this.spriteanime = new SpriteAnime(this.sprite, 0);
- this.bg1 = new Bg(this, 3);
- this.jglpad = new JglPad();
- this.field_0 = new Sound(this, 0);
- this.BGM = new Sound(this, 0);
- this.gameframe = new StgFrame(this);
- }
-
- public void start() {
- this.tMain = new Thread(this);
- if (this.tMain != null) {
- this.tMain.start();
- }
-
- }
-
- public void update(Graphics var1) {
- this.paintAll(var1);
- }
-
- public void paintAll(Graphics var1) {
- if (this.MovieHeight == 0) {
- var1.drawImage(this.iOffscreen, 0, 0, this);
- } else {
- var1.drawImage(this.iOffscreen, 0, this.MovieHeight, 320, 240 - this.MovieHeight * 2, this);
- }
- }
-
- public void run() {
- while(true) {
- this.StartFrame = System.currentTimeMillis();
- this.gameframe.run();
- this.spriteanime.action();
- this.bg1.paint(this.gOffscreen);
- this.sprite.paint(this.gOffscreen);
- this.curtain(this.gOffscreen, Color.black, this.CurtainHeight);
- this.Flush(this.gOffscreen, Color.white);
- ((Component)this).repaint();
- this.EndFrame = System.currentTimeMillis();
- this.WaitFrame = (long)this.RefreshRate - (this.EndFrame - this.StartFrame);
- if (this.WaitFrame > 0L) {
- try {
- Thread.sleep(this.WaitFrame);
- } catch (Exception var2) {
- }
- } else {
- try {
- Thread.sleep((long)this.RefreshRate);
- } catch (Exception var1) {
- }
- }
-
- this.jglpad.setNomal(this.KeyNomal);
- }
- }
-
- public void stop() {
- this.gameframe.stop();
- if (this.tMain != null) {
- this.tMain.stop();
- this.tMain = null;
- }
-
- }
-
- private void curtain(Graphics var1, Color var2, int var3) {
- if (var3 != 0) {
- this.gOffscreen.setColor(var2);
- this.gOffscreen.fillRect(0, 0, this.Width, var3);
- this.gOffscreen.fillRect(0, this.Height - var3, this.Width, this.Height);
- }
-
- }
-
- private void Flush(Graphics var1, Color var2) {
- if (this.fFlush) {
- this.gOffscreen.setColor(var2);
- this.gOffscreen.fillRect(0, 0, this.Width, this.Height);
- }
-
- }
-
- public boolean action(Event var1, Object var2) {
- return this.gameframe.action(var1, var2);
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- return this.gameframe.mouseUp(var1, var2, var3);
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- return this.gameframe.mouseDown(var1, var2, var3);
- }
-
- public boolean mouseMove(Event var1, int var2, int var3) {
- return this.gameframe.mouseMove(var1, var2, var3);
- }
-
- public boolean mouseDrag(Event var1, int var2, int var3) {
- return this.gameframe.mouseDrag(var1, var2, var3);
- }
-
- public boolean gotFocus(Event var1, Object var2) {
- this.fFocus = true;
- return this.gameframe.gotFocus(var1, var2);
- }
-
- public boolean lostFocus(Event var1, Object var2) {
- this.fFocus = false;
- return this.gameframe.lostFocus(var1, var2);
- }
-
- public void destroy() {
- this.gameframe.destroy();
- }
-
- public boolean keyDown(Event var1, int var2) {
- switch (var2) {
- case 50:
- case 1005:
- this.KeyNomal = (short)(this.KeyNomal | 32);
- break;
- case 52:
- case 1006:
- this.KeyNomal = (short)(this.KeyNomal | 64);
- break;
- case 54:
- case 1007:
- this.KeyNomal = (short)(this.KeyNomal | 128);
- break;
- case 56:
- case 1004:
- this.KeyNomal = (short)(this.KeyNomal | 16);
- break;
- case 67:
- case 99:
- this.KeyNomal = (short)(this.KeyNomal | 1);
- break;
- case 85:
- case 117:
- this.KeyNomal = (short)(this.KeyNomal | 2);
- break;
- case 88:
- case 120:
- this.KeyNomal = (short)(this.KeyNomal | 4);
- break;
- case 90:
- case 122:
- this.KeyNomal = (short)(this.KeyNomal | 8);
- }
-
- return true;
- }
-
- public boolean keyUp(Event var1, int var2) {
- switch (var2) {
- case 50:
- case 1005:
- this.KeyNomal = (short)(this.KeyNomal ^ 32);
- break;
- case 52:
- case 1006:
- this.KeyNomal = (short)(this.KeyNomal ^ 64);
- break;
- case 54:
- case 1007:
- this.KeyNomal = (short)(this.KeyNomal ^ 128);
- break;
- case 56:
- case 1004:
- this.KeyNomal = (short)(this.KeyNomal ^ 16);
- break;
- case 67:
- case 99:
- this.KeyNomal = (short)(this.KeyNomal ^ 1);
- break;
- case 85:
- case 117:
- this.KeyNomal = (short)(this.KeyNomal ^ 2);
- break;
- case 88:
- case 120:
- this.KeyNomal = (short)(this.KeyNomal ^ 4);
- break;
- case 90:
- case 122:
- this.KeyNomal = (short)(this.KeyNomal ^ 8);
- }
-
- return true;
- }
- }
-